package com.naiterui.ehp.bs.esign.controller.inner;

import com.naiterui.ehp.bp.support.exception.BusinessException;
import com.naiterui.ehp.bp.support.exception.PublicService;
import com.naiterui.ehp.bp.support.exception.ResponseVO;
import com.naiterui.ehp.bs.esign.service.IEsignService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

/**
 * @author guoyongxiang
 * @date 2019/12/3 16:31
 * @since 1.0.0
 */
@Slf4j
@RequestMapping("esign/inner/common")
@RestController
public class EsignInnerCommonController {

    @Autowired
    private IEsignService esignService;

    /**
     * 获取医网信签名账号配置（全局配置调用）
     *
     * @return
     *
     * @throws BusinessException
     */
    @PostMapping("ywx/sign/config")
    public ResponseVO<Map<String, String>> getYwxSignConfig() throws BusinessException {
        log.info("获取医网信签名账号配置");
        return PublicService.returnResponseVO(esignService.getYwxSignConfig());
    }

    /**
     * 按姓名生成个人签章（通用接口）
     * @param name
     * @return
     * @throws BusinessException
     */
    @PostMapping("personal/seal")
    public String getPersonalSeal(String name) throws BusinessException{
        log.info("按姓名生成个人签章: name={}", name);
        return esignService.createPersonalSeal(name, null, null);
    }

}
